<template>
  <div id="AllContributeHistory">

    <el-row>
      <mu-appbar title="历史金币总贡献" style="background-color:#409EFF">
        <mu-icon-button  icon="arrow_back_ios" slot="left" :to="{name: 'ContributeMenu' }"/>
      </mu-appbar>
    </el-row>

    <div class= "tools">
      <el-row>
        <el-col :xs="6" :sm="4" :md="3" :lg="3">
          起始日期
        </el-col>
        <el-col :xs="18" :sm="20" :md="21" :lg="21">
          <el-date-picker
            v-model="condition.startDay"
            type="date"
            placeholder="选择起始日期"
            size="mini"
            @change="getAll"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-col>
      </el-row>

      <el-row>
        <el-col :xs="6" :sm="4" :md="3" :lg="3">
          结束日期
        </el-col>
        <el-col :xs="18" :sm="20" :md="21" :lg="21">
          <el-date-picker
            v-model="condition.endDay"
            type="date"
            placeholder="选择结束日期"
            size="mini"
            @change="getAll"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-col>
      </el-row>
    </div>

    <el-row>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="usedNdot"
          label="总金币个数">
        </el-table-column>
        <el-table-column
          prop="date"
          label="日期">
        </el-table-column>
      </el-table>
    </el-row>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        tableData: [],
        condition: {
          startDay: this.$time.getDateBefore(new Date(), -3),
          endDay: this.$time.getDateBefore(new Date(), 0),
          account: sessionStorage.getItem('account')
        }
      }
    },
    methods: {
      init () {
        this.getAll()
      },
      getAll () {
        let that = this
        this.$axios({
          method: 'get',
          url: '/api/AgentService.getAllContributeHistory',
          params: this.condition
        })
        .then(function (resp) {
          if (resp.data.status === 'success') {
            that.tableData = resp.data.data
          } else {
            that.$message({
              showClose: true,
              message: resp.data.cause,
              type: 'warning'
            })
          }
        })
      }
    },
    mounted () {
      this.init()
    }
  }
</script>


<style>
#AllContributeHistory .el-row {
  margin-bottom: 16px;
}
#AllContributeHistory .el-col {
  margin-bottom: 8px;
}
</style>
